<?php

namespace backend\extensions;

use yii\base\BaseObject;

/**
 * Desc 所有服务的基类(必须继承)
 * @author HUI
 */
class ApiBaseService extends BaseObject
{

    /**
     * @desc   json出错返回
     * @param  string $msg
     * @return json
     */
    protected static function jsonError($message = '请求异常', $data = [])
    {
        return ['code' => 1, 'message' => $message, 'data' => $data];
    }

    /**
     * @desc   json成功返回
     * @param  array $data
     * @return json
     */
    protected static function jsonSuccess($data = [], $message = '请求成功')
    {
        return ['code' => 0, 'message' => $message, 'data' => $data];
    }
}
